package com.qidian.mes.qc.controller;/**
 * ClassName:CheckItemController
 * Package:com.qidian.mes.qc.controller
 **/

import com.qidian.mes.pojo.CheckItem;
import com.qidian.mes.qc.annotations.CheckParam;
import com.qidian.mes.qc.service.CheckItemService;
import com.qidian.mes.util.dot.PagerDTO;
import com.qidian.mes.util.pojo.QdResult;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @Author ppc
 * @Conpany study
 * @Description:
 * @Time 2024/4/5 14:05
 *
 **/
@CrossOrigin
@RestController
@RequestMapping("/checkItem")
public class CheckItemController {

    @Autowired
    private CheckItemService checkItemService;



    @RequestMapping("/updateByTemplate")
    public QdResult<CheckItem> updateByTemplate(@RequestBody @CheckParam(required = true) CheckItem checkItem ) {
        return checkItemService.updateByTemplate(checkItem);
    }
    @RequestMapping("/saveByTemplate")
    public QdResult<CheckItem> saveByTemplate(@RequestBody @CheckParam(required = true)CheckItem checkItem ) {
        return checkItemService.saveByTemplate(checkItem);
    }

    @RequestMapping("/queryByPage")
    public QdResult<PagerDTO<CheckItem>> queryByPage(@CheckParam(required = false)CheckItem checkItem, @CheckParam(type = Integer.class)@RequestParam(defaultValue = "1")int page,@CheckParam(type = Integer.class)@RequestParam(defaultValue = "10") int limit) {
        return checkItemService.queryByPage(checkItem, page, limit);
    }
    @RequestMapping("/queryByPageTemplate")
    public QdResult<PagerDTO<CheckItem>> queryByPageTemplate( String  templateId,@RequestParam(defaultValue = "1")int page,@RequestParam(defaultValue = "10") int limit) {
        return checkItemService.queryByPageTemplate(templateId, page, limit);
    }

    @RequestMapping("/queryAll")
    public QdResult<List<CheckItem>> queryAll() {
        return checkItemService.queryAll();
    }

    @RequestMapping("/save")
    public QdResult save(@RequestBody CheckItem checkItem) {
        return checkItemService.save(checkItem);
    }

    @RequestMapping("/update")
    public QdResult update(@RequestBody CheckItem checkItem) {
        return checkItemService.update(checkItem);
    }

    @RequestMapping("/delete")
    public QdResult delete(String checkItemId) {
        return checkItemService.delete(checkItemId);
    }

    @RequestMapping("/deletes")
    public QdResult deletes(String[] checkItemIds) {
        return checkItemService.deletes(checkItemIds);
    }

    @RequestMapping("/queryById")
    public QdResult queryById(String checkItemId) {
        return checkItemService.selectByCheckItemId(checkItemId);
    }

}
